#vertex shader

#version 130

uniform mat4 projectionMatrix;

in vec3 vertex_in;
in vec3 texcoord_in;

out vec3 texcoord;

void main() {
	//gl_TexCoord[0] = gl_MultiTexCoord0;
	//gl_TexCoord[1] = gl_MultiTexCoord1;
	
	texcoord = texcoord_in;
	
	gl_Position = projectionMatrix * vec4(vertex_in, 1.0);
}

#fragment shader

#version 130

uniform sampler2D tex2;
uniform sampler2D tex;
uniform sampler2D depthTexture;

uniform float maxDepth;

in vec3 texcoord;

out vec4 fragColor;

void main() {
	vec4 color = texture(tex, texcoord.xy);
	vec4 depthValue = texture(depthTexture, texcoord.xy);

	fragColor = color;
	gl_FragDepth = depthValue.x * maxDepth;
}